<?php


namespace catchAdmin\project\controller;


use app\common\business\Project;
use catchAdmin\project\request\AnswerRequest;
use catchAdmin\project\request\ProjectRequest;
use catcher\base\CatchController;
use catcher\base\CatchRequest;
use catcher\CatchResponse;
use catcher\exceptions\ValidateFailedException;
use think\exception\ValidateException;

class ChronicDisease extends CatchController
{
    protected $business = null;

    public function __construct()
    {
        $this->business = new \app\common\business\Answer();
    }


    public function index(CatchRequest $request)
    {
        $postData = $request->param();
        try {
            validate(AnswerRequest::class)->scene('chronicDisease')->check($postData);
            $result = $this->business->getChronicDisease($postData["his_id"], (int)$postData["estimate_type"]);
            return CatchResponse::success($result);
        } catch (ValidateException $validateException) {
            throw new ValidateFailedException($validateException->getMessage());
        }

    }

    public function save(CatchRequest $request)
    {
        $answerIds = [];
        $questionInfo = (new Project())->getProjectInfo("RXhtnq");
        $result = (new \app\common\business\Answer())->calculatingData("64d5f4b4aee64a74b63e511b", $questionInfo);
        print_r($result);
        exit();
    }
}